from django.db.models import *
from django.utils.translation import ugettext as _
educationChoices = (
		(1,_('junior college')),
		(2,_('undergraduate course')),
		(3,_('master')),
		(4,_('doctor')),
		(5,_('unlimited')),
)
locationChoices = (
		('tokyo',_('tokyo')),
		('osaka',_('osaka')),
		('beijing',_('beijing')),
		('shanghai',_('shanghai')),
		('shenzhen',_('shenzhen')),
		('guangzhou',_('guangzhou')),
		('dalian',_('dalian')),
)
industryChoices=(
		(1,'IT'),
		(2,_('trading company')),
		(3,_('medical treatment'))
	)
# 总用户表
class user(Model):
    email = EmailField(unique=True)
    password = CharField(max_length=66)
    loginTime = DateTimeField(auto_now=True)
    regTime = DateTimeField(auto_now_add=True)
    type = PositiveSmallIntegerField(default=1)
    name = CharField(max_length=25,null=True,blank=True)
    class Meta:
         db_table = "user"
# True 1 个人 2 企业 3 猎头(以后会考虑这个需求)
# 求职者
class member(Model):
	gender = BooleanField()
	realName = CharField(max_length=10)
	moblie = CharField(max_length=11)
	introduce = TextField(blank=True,null=True)
	workYear = PositiveSmallIntegerField()
	city = TextField(max_length=6)
	birthday = DateTimeField()
	uid = OneToOneField(user,primary_key=True)
	degree = PositiveSmallIntegerField(default=True,choices=educationChoices)
	head = ImageField(blank=True,null=True,upload_to="/static/images/")
	class Meta:
         db_table = "member"

# status 为求职状态 1 现在不想找 2 在职考虑换环境  3 我目前已离职，可快速到岗

# 公司
class company(Model):
	name = CharField(max_length=25)
	fullName = CharField(max_length=30)
	country = CharField(max_length=20)
	recommend = CharField(max_length=40)
	url = URLField()
	choices=(
		(1,'10人以内'),
		(2,'10 - 50人'),
		(3,'50 - 200人'),
		(4,'200人以上'),
	)
	peopleRange = PositiveIntegerField(blank=True,null=True,choices=choices)
	corporate = CharField(max_length=30) #法人
	location = CharField(choices = locationChoices,max_length=10)
	address = CharField(max_length=50)
	desc = TextField(blank=True,null=True)
	jpDesc = TextField(blank=True,null=True)
	establishTime = DateField(blank=True,null=True) #设立时间
	tel = CharField(max_length=12)
	moblie = CharField(max_length=13)
	linkman = CharField(max_length=8,blank=True,null=True) #联系人
	capital = CharField(max_length=15,blank=True,null=True)  #注册本金
	addressImg = FileField(null=True,blank=True)
	uid = OneToOneField(user,primary_key=True)
	logo = CharField(max_length=50,null=True,blank=True)
	cert = CharField(max_length=50,null=True,blank=True)
	status = BooleanField(default=False) #默认未审核
	industryType = PositiveSmallIntegerField(choices=industryChoices,null=True,blank=True)
	class Meta:
         db_table = "company"
         ordering = ["-uid"]

# 标签
class tag(Model):
	reid = PositiveIntegerField()
	tag = CharField(max_length=30)
	type = CharField(max_length=15)
	class Meta:
         db_table = "tag"

# 地址
class address(Model):
	name = CharField(max_length=20)
	jpname = CharField(max_length=20)
	addressImg = FileField()
	cityId = PositiveIntegerField()
	uid = ForeignKey(user)
	moblie = CharField(max_length=15)
	class Meta:
         db_table = "address"

# 教育经历
class education(Model):
	name =CharField(max_length=10)
	major = CharField(max_length=10)
	education = PositiveSmallIntegerField(choices=educationChoices)
	endTime = DateField()
	startTime = DateField()
	uid = ForeignKey(user)
	class Meta:
         db_table = "education"

# 工作经历
class work(Model):
	name = CharField(max_length=30)
	title = CharField(max_length=30)
	jpTitle = CharField(max_length=30,blank=True,null=True)
	startTime = DateField()
	endTime = DateField()
	content = TextField(blank=True,null=True)
	jpContent = TextField(blank=True,null=True)
	uid = ForeignKey(user)
	class Meta:
         db_table = "work"

# 社交主页
class social(Model):
	name = CharField(max_length=10)
	url = URLField()
	uid = ForeignKey(user)
	class Meta:
         db_table = "social"

# 技能等级
class evaluate(Model):
	name = CharField(max_length=20)
	level = PositiveSmallIntegerField()
	uid = ForeignKey(user)
	class Meta:
         db_table = "evaluate"

# 站内消息
class message(Model):
	content = TextField()
	to = ForeignKey(user) #送达人
	status = BooleanField(default=False) #True 已读 False 未读
	comeFrom = ForeignKey(user,related_name='fid') #发送人
	addTime = DateTimeField(auto_now_add=True)
	type = PositiveSmallIntegerField()
	class Meta:
         db_table = "message"
# type 1 kk广播(求职者)  2 通知 3 站内沟通 4 kk广播(企业) 
# 职位
class job(Model):
	name = CharField(max_length=20,null=True,blank=True)
	jpName = CharField(max_length=20)
	choices=(
		(1,'正社员'),
		(2,'契约社员')
	)
	country = CharField(max_length=20)
	type = PositiveSmallIntegerField(choices=choices)
	background = TextField(null=True,blank=True)
	jpBackground = TextField(null=True,blank=True)
	responsible = TextField(null=True,blank=True) #背景
	jpResponsible = TextField(null=True,blank=True) #职责
	demand = TextField(null=True,blank=True)
	jpDemand = TextField(null=True,blank=True) #要求
	jpPayment = CharField(max_length=20) #薪酬
	location = CharField(choices = locationChoices,max_length=10,null=True,blank=True)
	address = CharField(max_length=20,null=True,blank=True)
	num = PositiveSmallIntegerField()  #招募人数
	addTime = DateTimeField(auto_now_add=True)
	education = PositiveSmallIntegerField(choices=educationChoices)
	passed = BooleanField(default=False)
	uid = ForeignKey(company)
	year = PositiveSmallIntegerField(null=True,blank=True,default='') #工作年限
	status = BooleanField(default=True) #显示状态
	classify = CharField(max_length=20) #职位分类
	class Meta:
         db_table = "job"
         ordering = ["-addTime"]

# 收藏
class favorite(Model):
	jobId = PositiveIntegerField()	
	uid = PositiveIntegerField()
	addTime = DateTimeField(auto_now_add=True)
	class Meta:
         db_table = "favorite"


# 投递
class deliver(Model):
	comefrom = ForeignKey(member)
	job = ForeignKey(job)
	to = ForeignKey(company,null=True,blank=True)
	addTime = DateTimeField(auto_now_add=True)
	status = PositiveIntegerField()
	class Meta:
         db_table = "deliver"

# status 1 沟通中 2 拒绝 3 通过 4 收藏

# 文章
class article(Model):
	title = CharField(max_length=20)
	content = TextField()
	cover = CharField(max_length=50,null=True,blank=True)
	addTime = DateTimeField(auto_now_add=True)
	choices=(
		(1,_('live')),
		(2,_('work')),
		(3,_('encyclopedia')),
		(4,_('Japanese study')),
		(5,_('study abroad')),
	)
	type = PositiveSmallIntegerField(choices=choices)
	uid = ForeignKey(user)
	class Meta:
         db_table = "article"
         ordering = ["-addTime"]


